<?php
namespace app\api\validate;

use think\Validate;

/**
 * 会员数据验证器
 */
class User extends Validate
{

    protected $regex = [ 'phone' => '^1[3456789]\d{9}$'];
    /**
     * 验证规则
     */
    protected $rule = [
        'nickname' => 'require|min:2',
        'mobile'   => 'require|regex:phone',
        'avatar'   => 'require'
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'nickname.require' => '昵称必须',
        'nickname.min'     => '昵称至少2个字符',
        'mobile.require'   => '手机号必须',
        'mobile.regex'    => '值不是有效的手机号',
        'avatar.require'   => '头像必须',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'info' => ['nickname','mobile','avatar']
    ];
}
